<# Note
1. If you are running a 64 bit OS, you must use an x86 version of the PowerShell command line, 
2. at least with this version of Oracle.DataAccess which is only compatible on x86
#>

# --------------------------------------------------------Load Other Scripts---------------------------------------------------------------- 
. $PSScriptRoot\..\base.ps1 ;
. $PSScriptRoot\getAllColumnNames.ps1 ;

prepare_loadOracleAssembly;

function printForgedMapData ($config)
{
     $columnInfos = getAllColumnInfos $config;
    $desktopPath = getDesktopPath;

    foreach ($item in $columnInfos)
    {
        Write-Host ('fw.put("{0}","{1}")' -f
                                                                         $item.NAME,
                                                                         $item.VALUE
                               );
    }
}

function printForgedJSONData ($config)
{
  $columnInfos = getAllColumnInfos $config;
    $desktopPath = getDesktopPath;

    $result = ($columnInfos | %{ ( '\"{0}\":\"{1}\"' -f 
                                                                            $_.NAME.ToUpperInvariant(),
                                                                            $_.VALUE
                                                            )
                                                         }
                      ) -join ","
        ("`"{"+$result+"}`"") >  ([System.IO.Path]::Combine($desktopPath,"2.txt"));    
}
$config = @{
                        HOST = "172.16.1.29"; #127.0.0.1
                        PORT = "1521";
                        SID ="orcl";
                        USER_NAME = "jyxt";  #BDCDJ
                        PASSWORD = "kqgeojyxt";  #BDCDJ
                        TABLE_NAME = "JY_SPFHT";
                        };

# ==================================== Call ====================================================
#printForgedMapData $config
printForgedJSONData $config
